<template>
	<view class="content">
		<SideEdge :Dataindex='0'></SideEdge>
		<view class="right">
			<search></search>
			<view class="second">
				<view class="item">
					<view class="showText">
						<text class="one">{{study_duration}}</text>
						<text class="two">学习时长</text>
					</view>
					<image src="https://img.wilmer.com.cn/admin/2024/6-9/%E6%97%B6%E9%97%B4%402x.png" mode=""></image>
				</view>
				<view class="item">
					<view class="showText">
						<text class="one">{{question_num}}</text>
						<text class="two">做题总数</text>
					</view>
					<image src="https://img.wilmer.com.cn/admin/2024/6-9/%E7%9B%92%E5%AD%90%402x.png" mode=""></image>
				</view>
				<view class="item">
					<view class="showText">
						<text class="one">{{wrong_question_num}}</text>
						<text class="two">错题数量</text>
					</view>
					<image src="https://img.wilmer.com.cn/admin/2024/6-9/%E7%AC%94%E8%AE%B0%E6%9C%AC%402x.png" mode="">
					</image>
				</view>
				<view class="item">
					<view class="showText">
						<view class="one">{{correct}}<text style="font-size: 32px;">%</text></view>
						<text class="two">正确率</text>
					</view>
					<image src="https://img.wilmer.com.cn/admin/2024/6-9/%E5%B7%A5%E5%85%B7%402x.png" mode=""></image>
				</view>
			</view>
			<view class="title">
				<text>我的课程</text>
				<view class="backdrop"></view>
			</view>
			<view class="third">
				<view class="item" v-for="(item,index) in list" :key="index">
					<image class="cover" :src="item.logo" mode=""></image>
					<view class="linbox">
						<view class="information">
							<view class="infoLine">
								<text class="title">{{item.title}}</text>
								<view class="Number" :class="{No1: index == 0,No2: index == 1,No3: index == 2}">
									No.{{index + 1}}
								</view>
							</view>
							<text class="substring">{{item.desc}}</text>
						</view>
						<view class="btnBox">
							<view hover-class="checkActive" hover-stay-time='20' class="btn" @click="onTesting(item)">测
								试</view>
							<!-- <view hover-class="checkActive" hover-stay-time='20' class="btn" @click="onlearning(item)">学
								习</view> -->
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow
	} from "@dcloudio/uni-app"; // 该依赖已内置不需要单独安装
	import {
		subjectList
	} from '@/common/api/Notes.js'
	import {
		memberInfo
	} from '@/common/api/user.js'

	import {
		ref
	} from "vue"
	const list = ref([])

	function subjectData() {
		list.value = []
		subjectList().then(res => list.value = res.data)
	}
	subjectData()

	const correct = ref(0) // 正确率
	const wrong_question_num = ref(0) // 错题数量
	const question_num = ref(0) // 做题数量
	const study_duration = ref(0) // 学习时长

	function getInfo() {
		memberInfo().then(res => {
			correct.value = res.data.correct
			wrong_question_num.value = res.data.wrong_question_num
			question_num.value = res.data.question_num
			study_duration.value = res.data.study_duration
		})
	}

	function onTesting(item) {
		uni.navigateTo({
			url: `/pages/index/Question?subject_id=${item.id}`
		})
	}

	function onlearning(item) {
		uni.showToast({
			title: "敬请期待",
			icon: 'none'
		});
	}

	onShow(() => {
		getInfo()
		subjectData()
		uni.hideTabBar()
	})
</script>

<style>
	page {
		width: 100%;
		height: auto;
		background: #F7F7F7;
		overflow-x: hidden;
	}
</style>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		height: 100vh;
		display: flex;
		align-items: center;
		position: relative;
	}

	.right {
		width: calc(100vw - 300px);
		height: 100vh;
		overflow: overlay;

		.second {
			margin: 0 16px;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.item {
				width: 334px * 0.8;
				height: 196px * 0.8;
				background: #FFFFFF;
				border-radius: 12px;
				display: flex;
				align-items: center;
				justify-content: space-around;

				.showText {
					display: flex;
					flex-direction: column;

					.one {
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 64 * 0.8px;
						color: #040404;
						line-height: 1;
						text-align: left;
						font-style: normal;
					}

					.two {
						margin-top: 24px;
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 24 * 0.8px;
						color: #787774;
						line-height: 1;
						text-align: left;
						font-style: normal;
					}
				}
			}

			.item:nth-child(1) image {
				width: 89 * 0.6px;
				height: 106 * 0.6px;
			}

			.item:nth-child(2) image {
				width: 108 * 0.6px;
				height: 102 * 0.6px;
			}

			.item:nth-child(3) image {
				width: 108 * 0.6px;
				height: 116 * 0.6px;
			}

			.item:nth-child(4) image {
				width: 92 * 0.6px;
				height: 89 * 0.6px;
			}
		}

		.title {
			position: relative;
			margin-left: 20 * 0.8px;
			margin-top: 20 * 0.8px;

			text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 32px;
				color: #040404;
				line-height: 34px;
				text-align: left;
				font-style: normal;
				position: relative;
				z-index: 999;
			}

			.backdrop {
				width: 127px;
				position: relative;
				bottom: 15px;
				height: 13px;
				background: #2283E2;
			}
		}

		.third {
			max-height: calc(100vh - 140px - 160px - 40px);
			overflow: overlay;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			justify-content: flex-start;
			margin: 0 20 * 0.8px;
			padding-bottom: 30px;
			box-sizing: border-box;
			gap: 8px;

			.item {
				background: #FFFFFF;
				border-radius: 12px;
				padding: 20rpx 20rpx 0;
				padding-bottom: 10px;

				.cover {
					width: 430 * 0.8px;
					height: 186 * 0.8px;
				}

				.linbox {
					margin-top: 30 * 0.8px;
					margin-top: 24px;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.information {
						display: flex;
						flex-direction: column;
						align-items: flex-start;

						.infoLine {
							display: flex;
							align-items: center;

							.title {
								margin: 0;
								margin-right: 8px;
								font-family: PingFangSC, PingFang SC;
								font-weight: 600;
								font-size: 28rpx;
								color: #040404;
							}

							.Number {
								width: 49px;
								height: 22px;
								background: #787774;
								border-radius: 6px;

								display: flex;
								align-items: center;
								justify-content: center;

								font-family: PingFangSC, PingFang SC;
								font-weight: 600;
								font-size: 14px;
								color: #FFFFFF;

							}

							.No1 {
								background: #FE3D39;
							}

							.No2 {
								background: #2283E2;
							}

							.No3 {
								background: #FFB600;
							}
						}

						.substring {
							margin-top: 10px;
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							font-size: 16rpx;
							color: #B2B1AF;
						}
					}

					.btnBox {
						display: flex;

						.btn:nth-child(1) {
							color: #141414;
							background: #F8F8F8;
							margin-right: 16px;
						}

						.btn {
							width: 100 * 0.8px;
							height: 52 * 0.8px;
							background: #141414;
							border-radius: 12 * 0.8px;
							font-family: PingFangSC, PingFang SC;
							font-weight: 600 * 0.8;
							font-size: 20 * 0.8px;
							color: #FFFFFF;
							line-height: 18 * 0.8px;
							display: flex;
							align-items: center;
							justify-content: center;
						}
					}
				}
			}
		}
	}
</style>